//
//  XDErrProlblemNetWork.m
//  XDEducation
//
//  Created by 星道 on 17/5/15.
//  Copyright © 2017年 apple. All rights reserved.
//

#import "XDErrProlblemNetWork.h"

@implementation XDErrProlblemNetWork

//获取时间
+ (void)QueryForTime:(id)Model Success:(void (^)(id))Success Failure:(void (^)(NSError *))Failure;
{
    NSDictionary *dict = @{@"uid":[AccountTool shareAccountTool].currentAccount.uid};
    NSString *UrlStr = [NSString stringWithFormat:@"%@?action=%@",[(XDErrProblemHttpModel *)Model UrlFormat],[(XDErrProblemHttpModel *)Model TimeAction]];
    [XDHttpTool get:BaseURL(UrlStr) authCode:[AccountTool shareAccountTool].currentAccount.authCode params:dict success:^(id responseObj) {
        
        Success (responseObj);
        
    } failure:^(NSError *error) {
        
        Failure (error);
    }];
}



+ (void)QueryTypeForTime:(id)Model Success:(void (^)(id))Success Failure:(void (^)(NSError *))Failure;
{
    NSInteger Type;
    if ([Model isKindOfClass:[XDErrProblemKeQian class]])
    {
        Type = 1;
    }
    else
    {
        Type = 2;
    }
    NSDictionary *dict = @{@"uid":[AccountTool shareAccountTool].currentAccount.uid,@"type":@(Type)};
    NSString *UrlStr = [NSString stringWithFormat:@"%@?action=%@",[(XDErrProblemHttpModel *)Model UrlFormat],[(XDErrProblemHttpModel *)Model TimeAction]];
    [XDHttpTool get:BaseURL(UrlStr) authCode:[AccountTool shareAccountTool].currentAccount.authCode params:dict success:^(id responseObj) {
        
        Success (responseObj);
        
    } failure:^(NSError *error) {
        
        Failure (error);
    }];
    
}


//获取指定时间
+ (void)QueryForTime_Detail:(id)Model Success:(void (^)(id))Success Failure:(void (^)(NSError *))Failure;
{

    [self URLStr:Model Complete:^(NSString *UrlStr, NSDictionary *dict) {
        [XDHttpTool get:BaseURL(UrlStr) authCode:[AccountTool shareAccountTool].currentAccount.authCode params:dict success:^(id responseObj) {
            
            Success (responseObj);
            
        } failure:^(NSError *error) {
            
            Failure (error);
        }];
        
    }];
}

+ (void)URLStr:(id)Model Complete:(void(^)(NSString *,NSDictionary *))Complete
{
    NSString *uid = [AccountTool shareAccountTool].currentAccount.uid;
    if ([Model LeftIndex] == 2)
    {
        XDErrProblemQuanNeng *Model_Sub = (XDErrProblemQuanNeng *)Model;
        Complete (@"myresult.do?action=getStrengthErrorCount",@{@"uid":uid,@"querytime":Model_Sub.Querytime});
    }
    else if ([Model LeftIndex] == 3)
    {
        XDErrProblemKeQian *Model_Sub = (XDErrProblemKeQian *)Model;
        Complete (@"exercise.do?action=getErrorCountByTimeHw",@{@"uid":uid,@"querytime":Model_Sub.Querytime,@"type":@1});
    }
    else if ([Model LeftIndex] == 4)
    {
        XDErrProblemKeTang *Model_Sub = (XDErrProblemKeTang *)Model;
        Complete (@"exercise.do?action=getErrorCountByTimeHw",@{@"uid":uid,@"querytime":Model_Sub.Querytime,@"type":@2});
    }

    else
    {
        NSDictionary *dict = @{@"uid":[AccountTool shareAccountTool].currentAccount.uid,@"querytime":[(XDErrProblemHttpModel *)Model Querytime]};
        NSString *UrlStr = [NSString stringWithFormat:@"%@?action=%@",[(XDErrProblemHttpModel *)Model UrlTimeDetailFormat],[(XDErrProblemHttpModel *)Model TimeDetailAction]];
        Complete (UrlStr,dict);
    }
}




//获取复习巩固盲点详情
+ (void)QueryFuxiMangDian:(id)Model Success:(void (^)(id))Success Failure:(void (^)(NSError *))Failure
{
    XDErrProblemFuXi *FuXiModel = (XDErrProblemFuXi *)Model;
    NSDictionary *dict = @{
                           @"knowledge_id":FuXiModel.knowledge_id,
                           @"querytime"  : FuXiModel.Querytime,
                           @"uniqueKey"   :FuXiModel.uniqueKey,
                           @"uid"         :[AccountTool shareAccountTool].currentAccount.uid
                           };
    NSString *UrlStr = [NSString stringWithFormat:@"myresult.do?action=getdetailsbypointid"];
    [XDHttpTool get:BaseURL(UrlStr) authCode:[AccountTool shareAccountTool].currentAccount.authCode params:dict success:^(id responseObj) {
        
        Success (responseObj);
        
    } failure:^(NSError *error) {
        
        Failure (error);
    }];
}
@end
